package com.cjb.base.controller;

import com.cjb.base.dao.UserDao;
import com.cjb.base.domain.User;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserDao userDao;

    @PostMapping("/add")
    public void addUser(User user){

    }


    @GetMapping("/getall")
    @ResponseBody
    public List<User> getall(){
        Iterable<User> all = userDao.findAll();
        List<User> list=new ArrayList<User>();
        for (User user:all) {
            list.add(user);
        }
        return list;
    }

}
